package top.yuyufeng.mbuy.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yuyufeng.mbuy.dto.ShippingDTO;
import top.yuyufeng.mbuy.entity.Shipping;
import top.yuyufeng.mbuy.mapper.ShippingMapper;
import top.yuyufeng.mbuy.query.GetPostageQuery;
import top.yuyufeng.mbuy.service.IShippingService;
import top.yuyufeng.mbuy.utils.PageInfoUtil;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author yuyufeng7
 * @version v1.0
 * @date 2020/4/9
 */
@Service
public class ShippingServiceImpl implements IShippingService {

    @Autowired
    private ShippingMapper shippingMapper;

    @Override
    public List<ShippingDTO> listByUserId(Integer userId) {
        Shipping t = new Shipping();
        t.setUserId(userId);
        List<Shipping> list = shippingMapper.select(t);
        return PageInfoUtil.transPOList2DTOList(list,ShippingDTO.class);
    }

    @Override
    public BigDecimal calPostage(GetPostageQuery getPostageQuery) {
        return new BigDecimal(10);
    }
}
